package com.adjy.pathbuilders.objects;

import org.jbox2d.dynamics.contacts.Contact;

import com.adjy.pathbuilders.physics.PhysicalObject;
import com.adjy.pathbuilders.rendering.AnimationPack;
import com.adjy.pathbuilders.world.GameEntity;
import com.adjy.pathbuilders.world.MainChar;

/**
 * Box class implements a GameEntity Box<br>
 * This Entity can act like a wall if hit from the sides or like a floor if hit
 * from top
 */
public class Life extends GameEntity {
	
	public static final float[] SIZE = { 4, 4 };
	
	/**
	 * Creates a Box
	 * 
	 * @param x
	 *            X Position
	 * @param y
	 *            Y Position
	 * @param frame
	 *            Frame to be used for rendering
	 */
	public Life(int x, int y, AnimationPack ap) {
		super(GameEntityType.BOX, x, y, SIZE[0], SIZE[1], ap, false, false, false);
		setAnimation("life");
	}

	@Override
	public void hasStartedCollidingWith(PhysicalObject pObject, Contact contact) {
		if (pObject == null)
			return;
		if (!this.isDead() && ((GameEntity) pObject).getType() == GameEntityType.MAINCHAR) { // Collided
																			// with
																			// Player
			MainChar c = (MainChar) pObject;
			c.gotOneLife();
			kill();

		}
	}
}
